package com.qf.forumproject.blog.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.qf.forumproject.blog.dao.QfBlogDao;
import com.qf.forumproject.entity.QfBlog;
import com.qf.forumproject.entity.QfBlogCategory;
import com.qf.forumproject.blog.dao.QfBlogCategoryDao;
import com.qf.forumproject.blog.service.QfBlogCategoryService;
import com.qf.forumproject.utils.ResultVo;
import com.qf.forumproject.utils.SearchVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * (QfBlogCategory表)服务实现类
 *
 * @author protagonist
 * @since 2022-07-23 11:42:23
 */
@Service("qfBlogCategoryServiceImpl")
public class QfBlogCategoryServiceImpl extends ServiceImpl<QfBlogCategoryDao,QfBlogCategory> implements QfBlogCategoryService {
    @Resource
    private QfBlogCategoryDao qfBlogCategoryDao;


    @Autowired
    private QfBlogDao qfBlogDao;

    /**
     * 查询所有
     *
     * @return 实例对象的集合
     */
    @Override
    public List<QfBlogCategory> selectAll() {
        return this.list();
    }


    /**
     * 拿到博客分类的id去博客文章表中查询该类别的文章
     * @param blogSearchVo
     * @return
     */
    @Override
    public List<ResultVo> selectByBlogCategoryId(SearchVo blogSearchVo) {

        //PageHelper.startPage(blogSearchVo.getPage(),blogSearchVo.getLimit());

        /*QueryWrapper<QfBlog> queryWrap = new QueryWrapper<>();
        queryWrap.eq("category_id",blogSearchVo.getCategoryId());*/

        //return qfBlogDao.selectList(queryWrap);
        return qfBlogCategoryDao.selectbyCategoryId(blogSearchVo.getCategoryId());
    }
}
